import Vue from 'vue'
import Vuex from 'vuex'
// import appConfig from '@/config/config.js'
// import {
// 	saveStateKeys,
// 	appTabbar,
// 	appTabbar2
// } from './config.js'
Vue.use(Vuex)

// 保存变量到本地存储中
const saveLifeData = function(key, value) {

	uni.setStorageSync(key, value);
}
let appTabbarToken = 1

if (uni.getStorageSync('vuex_tabbar')) {
	appTabbarToken = uni.getStorageSync('vuex_tabbar')
	
} else {
	appTabbarToken = 1
}
const store = new Vuex.Store({
	state: {
		vuex_tabbar: appTabbarToken
	},
	mutations: {
		choiceOne(state) {
			uni.setTabBarItem({
				"index": 0,
				"text": '案场统计',
				success() {
					uni.switchTab({
						url: '/pages/index/index'
					})
				}

			})


			state.vuex_tabbar = 2
			uni.removeTabBarBadge({
				index: 0
			})
			// uni.switchTab({
			// 	url: `/pages/fieldStatistics/fieldStatistics`
			// });
			saveLifeData('vuex_tabbar', 2)
		},
		choiceTwo(state) {

			uni.setTabBarItem({
				"index": 0,
				"text": "待办",
				success() {
					uni.switchTab({
						url: '/pages/index/index'
					})
				}

			})


			uni.setTabBarBadge({
				index: 0,
				text: '1'
			})
			// uni.switchTab({
			// 	url: `/pages/backlog/backlog`
			// });
			state.vuex_tabbar = 1
			saveLifeData('vuex_tabbar', 1)
		}
	}
})

export default store
